# -*- coding: utf-8 -*-
# @Time    : 2022/2/18 15:29
# @Author  : Cph
# @File    : add_.py
# @remarks :更改密码
import time
from selenium.webdriver import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium import webdriver

# 个人资料路径
user_data_dir = (r'--user-data-dir=C:\Users\陈品华\AppData\Local\Google\Chrome\User Data')
# 加载配置数据
option = webdriver.ChromeOptions()
option.add_argument(user_data_dir)

_list = ['hzsdsjj_028']
for a in _list:
    driver = webdriver.Chrome()
    driver.maximize_window()
    print(a)
    # 网址/地址
    url = 'https://10.10.142.221:8015/ucbb/static/login'
    # 启动网页
    driver.get(url)
    # 安全警告 高级-继续
    # driver.find_element_by_xpath('//*[@id="details-button"]').click()
    # driver.find_element_by_xpath('//*[@id="proceed-link"]').click()
    time.sleep(1)
    username = driver.find_element_by_xpath('//*[@id="username"]')
    username.send_keys(a)
    password = driver.find_element_by_xpath('//*[@id="password"]')
    password.send_keys('Abc123#$')
    time.sleep(0.3)
    driver.find_element_by_xpath('//*[@id="root"]/div/div/div[6]/div/div/div/form/button').click()
    time.sleep(1)
    # 修改密码
    oldPassword = driver.find_element_by_xpath('//*[@id="oldPassword"]').send_keys('Abc123#$')
    driver.find_element_by_xpath('//*[@id="newPassword"]').send_keys('Abc123#$1')
    driver.find_element_by_xpath('//*[@id="newPasswordConfirm"]').send_keys('Abc123#$1')
    # 确认
    driver.find_element_by_xpath('/html/body/div[2]/div/div[2]/div/div[2]/div[3]/button').click()
    time.sleep(1.5)
    driver.close()

